<?php
    // 父类 car
    class Car{
        public $color;
        public $userName;

        public function ___construct($color,$userName){
            $this->color = $color;
            $this->userName = $userName;
        }
        public function use(){
            echo "我是机动车";
        }

        public function equals($obj1,$obj2){
            if(($obj1->color==$obj2->color)&&($obj1->userName==$obj2->userName)){
                return true;
                return false;
            }
        }
    }
    // 测试
    // $car1 = new Car("红色","zhangsan");

    // $car2 = new Car("黄色","lisi");

    // $car1->use();
    // var_dump($car->equals($car1,$car2));
    class Taxi extends Car{
        public $company;
        public function __construct($company,$color,$userName)
        {
            $this->company=$company;
            parent::___construct($color,$userName);   //调用父类的构造函数

        }
        final public function ride(){
            echo $this->userName."出租车是所属于在".$this->company."公司的";
        }
        final public function use(){
            echo "出租车是提高市民生活质量的重要条件之一";
        }

        final public function toString(){
            echo $this->color."<br>";
            echo $this->userName;
        }

    }

    class HomeCar extends Taxi{
        public $num;
        public function __construct($num,$company,$color,$userName){
            $this->num=$num;
            parent::___construct($company,$color,$userName);
        }
        public function dispaly(){
            echo $this->userName."拥有的".$this->color."颜色的私家车与".$this->num."座位";
        }
    }
    
?>


